package com.tarena.lbs.basic.web.controller;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.basic.web.service.TagService;
import com.tarena.lbs.pojo.basic.param.UserTagsParam;
import com.tarena.lbs.pojo.basic.vo.ArticleTagVO;
import com.tarena.lbs.pojo.basic.vo.TagVO;
import com.tarena.lbs.pojo.basic.vo.UserTagVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class TagController {
    @Autowired
    private TagService tagService;
    @GetMapping("/basic/tagLibrary/info/article/tags")
    public Result<Map<String, List<TagVO>>> getArticleTags()
        throws BusinessException{
        Map<String,List<TagVO>> vos=tagService.articleTags();
        return new Result<>(vos);
    }
    //历史遗留的接口 影响map标签查询
    @GetMapping("/basic/tagLibrary/info/articleList")
    public Result<Void> getArticleTagsList()
            throws BusinessException{
        return Result.success();
    }
    @GetMapping("/basic/tagLibrary/info/articleAllList")
    public Result<Map<String, List<TagVO>>> getArticleTagsAllList()
            throws BusinessException{
        Map<String,List<TagVO>> vos=tagService.articleTags();
        return new Result<>(vos);
    }
    //用户标签
    @GetMapping("/basic/tagLibrary/info/userList")
    public Result<Map<String,List<TagVO>>> getUserTags(){
        Map<String,List<TagVO>> vos=tagService.userTags();
        return new Result<>(vos);
    }
    @GetMapping("/basic/tagLibrary/info/user/tags")
    public Result<Map<String,List<TagVO>>> getUserTags2(){
        Map<String,List<TagVO>> vos=tagService.userTags();
        return new Result<>(vos);
    }
    @GetMapping("/basic/user/tag")
    public Result<Void> bindUserTags(UserTagsParam param)
        throws BusinessException{
        tagService.bindUserTags(param);
        return Result.success();
    }
}
